const util = require('../../utils/util.js');
const api = require('../../config/api.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    ads: [],
    products: [],
    aboutProduct: [],
    indicatorDots: true,
    interval: 5000,
    duration: 1000,
    user: {}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.getIndexData();


  },
  onShow: function() {
    this.setData({
      user: wx.getStorageSync('user')
    });
  },
  getIndexData: function() {
    let that = this;
    util.request(api.IndexUrl).then(function(res) {
      if (res.success) {
        that.setData({
          products: res.data.products,
          ads: res.data.ads,
          aboutProduct: res.data.aboutProduct
        });
      }
    });
  },
  toLogin: function() {
    wx.navigateTo({
      url: '/pages/register/register1/register1'
    })
  },
  onShareAppMessage: function() {
    return {
      title: this.postData.title,
      desc: this.postData.content,
      path: "pages/home/home"
    }
  },
  toSkip:function(e){
    let url = e.currentTarget.dataset.url
    if(url){
      wx.navigateTo({
        url:url
      })
    }
  },
  toUser:function(){
    wx.switchTab({
      url: "/pages/vip/master/master"
    })
  }

})